<!DOCTYPE html>
<html lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="author" content="qq">



<meta name="description" content="因为创新实践课的需要，lion最近在研究三维网格平面参数化这篇论文，在这篇文章中，先将记录下自己对Tutte的&amp;quot;barycentric mapping&amp;quot;方法的理解，相关代码等实现了再更新到这篇文章中。">
<meta name="keywords" content="C&#x2F;C++">
<meta property="og:type" content="article">
<meta property="og:title" content="三维网格平面参数化(一)">
<meta property="og:url" content="http://huaqq.github.io/2018/11/16/三维网格平面参数化(一)/index.html">
<meta property="og:site_name" content="Lionqq&#39;s Blog">
<meta property="og:description" content="因为创新实践课的需要，lion最近在研究三维网格平面参数化这篇论文，在这篇文章中，先将记录下自己对Tutte的&amp;quot;barycentric mapping&amp;quot;方法的理解，相关代码等实现了再更新到这篇文章中。">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$${\mu_i}=\sum_{j=1}^N\lambda_{i,j}*\mu_j,i=1,...,n$$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$\mu_i,\mu_j$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$\lambda_{i,j}$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$$\begin{cases}&space;\lambda_{i,j}=0,(i,j)\notin&space;E\\&space;\lambda_{i,j}>0,(i,j)\in&space;E,&space;\sum_{j=1}^N\lambda_{i,j}=1&space;\end{case}&space;$$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$\lambda$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$\lambda$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$i$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$2\pi$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$$\mu_i-\sum_{j=1}^n\lambda_{i,j}*\mu_j=\sum_{j=n+1}^N\lambda_{i,j}*\mu_j$$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$\mu$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$x,y$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$$Ax=b_1,Ay=b_2$$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$A$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$n*n$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$n$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$A$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$$\begin{cases}&space;a_{i,j}=1,i=j\\&space;a_{i,j}=-\lambda_{i,j},i\neq&space;j&space;\end{cases}&space;$$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$b_1,b_2$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$x,y$">
<meta property="og:image" content="https://latex.codecogs.com/gif.latex?$x,y$">
<meta property="og:image" content="http://huaqq.github.io/2018/11/16/三维网格平面参数化(一)/test.jpg">
<meta property="og:image" content="http://huaqq.github.io/2018/11/16/三维网格平面参数化(一)/jieguo.jpg">
<meta property="og:image" content="http://huaqq.github.io/2018/11/16/三维网格平面参数化(一)/test2.jpg">
<meta property="og:image" content="http://huaqq.github.io/2018/11/16/三维网格平面参数化(一)/jieguo2.jpg">
<meta property="og:updated_time" content="2018-11-27T15:52:31.862Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="三维网格平面参数化(一)">
<meta name="twitter:description" content="因为创新实践课的需要，lion最近在研究三维网格平面参数化这篇论文，在这篇文章中，先将记录下自己对Tutte的&amp;quot;barycentric mapping&amp;quot;方法的理解，相关代码等实现了再更新到这篇文章中。">
<meta name="twitter:image" content="https://latex.codecogs.com/gif.latex?$${\mu_i}=\sum_{j=1}^N\lambda_{i,j}*\mu_j,i=1,...,n$$">

<link rel="apple-touch-icon" href="/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="Lionqq&#39;s Blog" type="application/atom+xml">



    <link rel="shortcut icon" href="/bitbug_favicon.ico">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>三维网格平面参数化(一) | Lionqq&#39;s Blog</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>





    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?9403eb8c3e1afbd49d6eafbef0cf66e5";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head></html>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/tx.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">qq</a></h1>
        </hgroup>

        
        <p class="header-subtitle">仙人抚我顶，结发受长生</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="">
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class="no-result">No results found <i class="fa fa-spinner fa-pulse"></i></p>
        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/tags/">标签云</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="/1076817937@qq.com" title="Email"></a>
                            
                                <a class="fa GitHub" href="#" title="GitHub"></a>
                            
                                <a class="fa RSS" href="/atom.xml" title="RSS"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/C-C/">C/C++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/">Java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Spring/">Spring</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Three-js/">Three.js</a></li></ul>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">qq</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/tx.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">qq</a></h1>
            </hgroup>
            
            <p class="header-subtitle">仙人抚我顶，结发受长生</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/tags/">标签云</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="/1076817937@qq.com" title="Email"></a>
                            
                                <a class="fa GitHub" target="_blank" href="#" title="GitHub"></a>
                            
                                <a class="fa RSS" target="_blank" href="/atom.xml" title="RSS"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我">
</nav>
      <div class="body-wrap"><article id="post-三维网格平面参数化(一)" class="article article-type-post" itemscope="" itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2018/11/16/三维网格平面参数化(一)/" class="article-date">
      <time datetime="2018-11-15T18:00:49.000Z" itemprop="datePublished">2018-11-16</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      三维网格平面参数化(一)
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        

        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/C-C/">C/C++</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <p>因为创新实践课的需要，lion最近在研究<a href="https://www.sciencedirect.com/science/article/abs/pii/S0167839696000313" target="_blank" rel="noopener">三维网格平面参数化</a>这篇论文，在这篇文章中，先将记录下自己对Tutte的&quot;barycentric mapping&quot;方法的理解，相关代码等实现了再更新到这篇文章中。</p>
<a id="more"></a>
<h2 id="方法思想"><a class="markdownIt-Anchor" href="#方法思想"></a> 方法思想</h2>
<p>这是一种重心映射的方式，即三维网格点映射到二维平面后的位置是由其在三维网格中1-邻域的点共同决定的，可以写成如下形式：</p>
<p><img src="https://latex.codecogs.com/gif.latex?$${\mu_i}=\sum_{j=1}^N\lambda_{i,j}*\mu_j,i=1,...,n$$" title="$${\mu_i}=\sum_{j=1}^N\lambda_{i,j}*\mu_j,i=1,...,n$$"> (式1)</p>
<p>式中<img src="https://latex.codecogs.com/gif.latex?$\mu_i,\mu_j$" title="$\mu_i,\mu_j$">表示映射至二维平面中的点，<img src="https://latex.codecogs.com/gif.latex?$\lambda_{i,j}$" title="$\lambda_{i,j}$">与点邻接有关可以表示如下：<br>
<img src="https://latex.codecogs.com/gif.latex?$$\begin{cases}&space;\lambda_{i,j}=0,(i,j)\notin&space;E\\&space;\lambda_{i,j}>0,(i,j)\in&space;E,&space;\sum_{j=1}^N\lambda_{i,j}=1&space;\end{case}&space;$$" title="$$\begin{cases} \lambda_{i,j}=0,(i,j)\notin E\\ \lambda_{i,j}>0,(i,j)\in E, \sum_{j=1}^N\lambda_{i,j}=1 \end{case} $$"> (式2)<br>
即不相连的点之间的<img src="https://latex.codecogs.com/gif.latex?$\lambda$" title="$\lambda$">为0，相连的点之间的 <img src="https://latex.codecogs.com/gif.latex?$\lambda$" title="$\lambda$"> 为<img src="https://latex.codecogs.com/gif.latex?$i$" title="$i$">th点的1-邻域的度数的倒数。</p>
<hr>
<h2 id="方法步骤"><a class="markdownIt-Anchor" href="#方法步骤"></a> 方法步骤</h2>
<blockquote>
<ol>
<li>寻找网格边界点</li>
<li>将网格边界点映射到圆周上</li>
<li>根据点的邻接关系计算稀疏矩阵A</li>
<li>A是非奇异矩阵，故方程组有唯一解</li>
</ol>
</blockquote>
<h3 id="1-寻找网格边界点"><a class="markdownIt-Anchor" href="#1-寻找网格边界点"></a> 1. 寻找网格边界点</h3>
<p>在这里我们用到了<a href="http://xueshu.baidu.com/usercenter/paper/show?paperid=95c16f3635825167cdcbf888f9df127c&amp;site=xueshu_se" target="_blank" rel="noopener">一种空间三角网格边界提取方法</a>。也就是遍历网格所有的点，对每个点再遍历其邻接三角形集合，用一个数组存放这一邻接三角形中异于该点的另外两个点。存放进数组之前判断数组中是否已存在待存放点，若存在则删除数组中的这个点，若不存在则添加进数组中。最后的结果为，边界点的这一数组中存放了另外两个邻接边界点的索引，而内部点的数组是空的。以下是lion寻找边界的代码：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">FindBorder</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	<span class="comment">//构造各点的邻接三角形集合 含有重复</span></span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; F.rows(); i++) &#123;</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; <span class="number">3</span>; j++) &#123;</span><br><span class="line">			vtNeibor[F(i, j)].push_back(i);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="comment">//去除重复出现的元素</span></span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; V.rows(); i++) &#123;</span><br><span class="line">		<span class="built_in">std</span>::sort(vtNeibor[i].begin(), vtNeibor[i].end());</span><br><span class="line">		vtNeibor[i].erase(unique(vtNeibor[i].begin(), vtNeibor[i].end()), vtNeibor[i].end());</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="comment">//寻找各点邻接边界点</span></span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; V.rows(); i++) &#123;</span><br><span class="line">		<span class="keyword">int</span> temp[<span class="number">20</span>], tIndex = <span class="number">0</span>;<span class="comment">//暂时保存某个点的邻接边界点 并初始化为-1 </span></span><br><span class="line">		<span class="keyword">while</span> (tIndex &lt; <span class="number">20</span>) &#123;</span><br><span class="line">			temp[tIndex++] = <span class="number">-1</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">int</span> tempIndex = <span class="number">0</span>;</span><br><span class="line">		<span class="comment">//遍历该点所有邻接三角网格 构造temp</span></span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; vtNeibor[i].size(); j++) &#123;</span><br><span class="line">			<span class="keyword">for</span> (<span class="keyword">int</span> k = <span class="number">0</span>; k &lt; <span class="number">3</span>; k++) &#123;</span><br><span class="line">				<span class="keyword">if</span> (F(vtNeibor[i][j], k) != i) &#123;<span class="comment">//异于当前点</span></span><br><span class="line">					vvNeibor[i].push_back(F(vtNeibor[i][j], k));</span><br><span class="line">					<span class="keyword">int</span> exist_flag = <span class="number">-1</span>;<span class="comment">//若存在于temp中 返回存在的位置</span></span><br><span class="line">					<span class="keyword">for</span> (<span class="keyword">int</span> kk = <span class="number">0</span>; kk &lt; <span class="number">20</span>; kk++) &#123;</span><br><span class="line">						<span class="keyword">if</span> (temp[kk] != <span class="number">-1</span> &amp;&amp; temp[kk] == F(vtNeibor[i][j], k)) &#123;</span><br><span class="line">							exist_flag = kk;</span><br><span class="line">						&#125;</span><br><span class="line">					&#125;</span><br><span class="line">					<span class="keyword">if</span> (exist_flag != <span class="number">-1</span>) &#123;</span><br><span class="line">						temp[exist_flag] = <span class="number">-1</span>;<span class="comment">//找到了 删除这个点</span></span><br><span class="line">					&#125;</span><br><span class="line">					<span class="keyword">else</span> &#123;</span><br><span class="line">						temp[tempIndex++] = F(vtNeibor[i][j], k);</span><br><span class="line">					&#125;</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">int</span> nulFlag = <span class="number">1</span>;<span class="comment">//0为非空 1为空</span></span><br><span class="line">		<span class="keyword">int</span> jj = <span class="number">0</span>;</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; <span class="number">20</span>; j++) &#123;</span><br><span class="line">			<span class="keyword">if</span> (temp[j] != <span class="number">-1</span>) &#123;</span><br><span class="line">				nulFlag = <span class="number">0</span>;</span><br><span class="line">				AdjPtsIndex[i][jj++] = temp[j];<span class="comment">//把各点temp中剩余的两个点下标存入</span></span><br><span class="line">											   <span class="comment">//即该边界点的另外两个相邻边界点</span></span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span> (nulFlag != <span class="number">1</span>) &#123;</span><br><span class="line">			isBorder[i] = <span class="number">1</span>;</span><br><span class="line">			<span class="comment">//NumAdjPts[i] = 2;</span></span><br><span class="line">			numBorder++;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="comment">//到此 应找出所有的边界点 及其作为边界点时的邻接边界点</span></span><br><span class="line">	<span class="comment">//对vvNeibor[i]去重 得到各点的邻接表</span></span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; V.rows(); i++) &#123;</span><br><span class="line">		<span class="built_in">std</span>::sort(vvNeibor[i].begin(), vvNeibor[i].end());</span><br><span class="line">		vvNeibor[i].erase(unique(vvNeibor[i].begin(), vvNeibor[i].end()), vvNeibor[i].end());</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	newBorder.resize(numBorder);</span><br><span class="line">	unorderBorder.resize(numBorder);</span><br><span class="line">	<span class="keyword">int</span> temp2 = <span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; V.rows(); i++) &#123;</span><br><span class="line">		<span class="keyword">if</span> (isBorder[i] == <span class="number">1</span>)</span><br><span class="line">			unorderBorder[temp2++] = i;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​</p>
<h3 id="2-边界点映射到二维平面上"><a class="markdownIt-Anchor" href="#2-边界点映射到二维平面上"></a> 2. 边界点映射到二维平面上</h3>
<p>lion是将边界点映射到一个单位圆上的。因为三维网格的点映射到二维平面以后拓扑关系是不变的，所以各边界点距离起点边界点的位置占边界总长的比例*<img src="https://latex.codecogs.com/gif.latex?$2\pi$" title="$2\pi$">，就是这个边界点在这个单位圆的弧度，再利用数学公式即可算出坐标。以下是构造有序边界的代码：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">orderBorder</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	newBorder[<span class="number">0</span>] = unorderBorder[<span class="number">0</span>];<span class="comment">//定起点</span></span><br><span class="line">	newBorder[<span class="number">1</span>] = AdjPtsIndex[newBorder[<span class="number">0</span>]][<span class="number">0</span>];<span class="comment">//定方向</span></span><br><span class="line">	mapBorder[newBorder[<span class="number">0</span>]] = <span class="number">0</span>;</span><br><span class="line">	mapBorder[newBorder[<span class="number">1</span>]] = <span class="number">1</span>;</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">2</span>; i &lt; numBorder; i++) &#123;</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; <span class="number">2</span>; j++) &#123;</span><br><span class="line">			<span class="keyword">if</span> (AdjPtsIndex[newBorder[i - <span class="number">1</span>]][j] != newBorder[i - <span class="number">2</span>]) &#123;</span><br><span class="line">				newBorder[i] = AdjPtsIndex[newBorder[i - <span class="number">1</span>]][j];</span><br><span class="line">				mapBorder[newBorder[i]] = i;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	numInner = V.rows() - numBorder;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>然后是把有序边界点映射到圆周上：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">CirBorder</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	Distan.resize(numBorder + <span class="number">1</span>, <span class="number">0</span>);<span class="comment">//最后一个是总长</span></span><br><span class="line">	uvBorder.resize(numBorder, <span class="number">2</span>);</span><br><span class="line">	uvBorder.setZero();</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i &lt; numBorder+<span class="number">1</span>; i++) &#123;</span><br><span class="line">		Distan[i] = Distan[i - <span class="number">1</span>] + (V.row(newBorder[i%numBorder]) - V.row(newBorder[i - <span class="number">1</span>])).norm();</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; numBorder; i++) &#123;</span><br><span class="line">		<span class="keyword">double</span> delta = <span class="number">2.</span>*PI*Distan[i] / Distan[numBorder];</span><br><span class="line">		uvBorder.row(i) &lt;&lt; <span class="built_in">cos</span>(delta), <span class="built_in">sin</span>(delta);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="3-构造稀疏矩阵a"><a class="markdownIt-Anchor" href="#3-构造稀疏矩阵a"></a> 3. 构造稀疏矩阵A</h3>
<p>边界点的映射之后<span class="katex-error" title="ParseError: KaTeX parse error: Expected &#039;EOF&#039;, got &#039;式&#039; at position 2: (式̲2)">(式2)</span>可以移项成如下形式：<br>
<img src="https://latex.codecogs.com/gif.latex?$$\mu_i-\sum_{j=1}^n\lambda_{i,j}*\mu_j=\sum_{j=n&plus;1}^N\lambda_{i,j}*\mu_j$$" title="$$\mu_i-\sum_{j=1}^n\lambda_{i,j}*\mu_j=\sum_{j=n+1}^N\lambda_{i,j}*\mu_j$$">(式3)<br>
其中1到n为内部点，n+1到N为边界点，故式子最终将已知的归在一边，未知的归在一边。(式3)的<img src="https://latex.codecogs.com/gif.latex?$\mu$" title="$\mu$">可以分解为<img src="https://latex.codecogs.com/gif.latex?$x,y$" title="$x,y$">两个坐标分量，化简为如下两个方程：<br>
<img src="https://latex.codecogs.com/gif.latex?$$Ax=b_1,Ay=b_2$$" title="$$Ax=b_1,Ay=b_2$$">(式4)<br>
其中<img src="https://latex.codecogs.com/gif.latex?$A$" title="$A$">为<img src="https://latex.codecogs.com/gif.latex?$n*n$" title="$n*n$">的矩阵(<img src="https://latex.codecogs.com/gif.latex?$n$" title="$n$">为内部点的个数)，<img src="https://latex.codecogs.com/gif.latex?$A$" title="$A$">的各元素可以表示为如下形式：<br>
<img src="https://latex.codecogs.com/gif.latex?$$\begin{cases}&space;a_{i,j}=1,i=j\\&space;a_{i,j}=-\lambda_{i,j},i\neq&space;j&space;\end{cases}&space;$$" title="$$\begin{cases} a_{i,j}=1,i=j\\ a_{i,j}=-\lambda_{i,j},i\neq j \end{cases} $$">(式5)</p>
<p>稀疏矩阵A的构造如下：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">MatrixA</span><span class="params">()</span> </span>&#123;</span><br><span class="line">	uList.resize(V.rows(), <span class="number">-1</span>);</span><br><span class="line">	mapList.resize(V.rows(), <span class="number">-1</span>);</span><br><span class="line">	<span class="keyword">int</span> order_temp = <span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; V.rows(); i++) &#123;</span><br><span class="line">		<span class="keyword">if</span> (isBorder[i] != <span class="number">1</span>) &#123;</span><br><span class="line">			<span class="comment">//先放内部点</span></span><br><span class="line">			uList[order_temp] = i;</span><br><span class="line">			mapList[i] = order_temp;</span><br><span class="line">			order_temp++;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; numBorder; i++) &#123;</span><br><span class="line">		uList[order_temp] = unorderBorder[i];</span><br><span class="line">		mapList[unorderBorder[i]] = order_temp;</span><br><span class="line">		order_temp++;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="comment">//for(int i=0;i&lt;V.rows();i++)</span></span><br><span class="line">	<span class="comment">//	std::cout &lt;&lt; i &lt;&lt; " "  &lt;&lt; mapList[i] &lt;&lt; std::endl;</span></span><br><span class="line"></span><br><span class="line">	<span class="comment">//每个点的度数就是vvNeibor[i]的size</span></span><br><span class="line">	A.resize(numInner, numInner);</span><br><span class="line">	A.setZero();</span><br><span class="line">	bx.resize(numInner);</span><br><span class="line">	bx.setZero();</span><br><span class="line">	by.resize(numInner);</span><br><span class="line">	by.setZero();</span><br><span class="line"></span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; numInner; i++) &#123;</span><br><span class="line">		A(i, i) = <span class="number">1</span>;</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; vvNeibor[uList[i]].size(); j++) &#123;</span><br><span class="line">			<span class="keyword">if</span> (isBorder[vvNeibor[uList[i]][j]] == <span class="number">0</span>) &#123;</span><br><span class="line">				A(i,mapList[vvNeibor[uList[i]][j]])=<span class="number">-1.</span>/ vvNeibor[uList[i]].size();</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">else</span> &#123;</span><br><span class="line">				bx(i, <span class="number">0</span>) += uvBorder(mapBorder[vvNeibor[uList[i]][j]], <span class="number">0</span>);</span><br><span class="line">				by(i, <span class="number">0</span>) += uvBorder(mapBorder[vvNeibor[uList[i]][j]], <span class="number">1</span>);</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span> (bx(i, <span class="number">0</span>) != <span class="number">0</span>)</span><br><span class="line">			bx(i, <span class="number">0</span>) /= vvNeibor[uList[i]].size();</span><br><span class="line">		<span class="keyword">if</span> (by(i, <span class="number">0</span>) != <span class="number">0</span>)</span><br><span class="line">			by(i, <span class="number">0</span>) /= vvNeibor[uList[i]].size();</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="4-求解方程"><a class="markdownIt-Anchor" href="#4-求解方程"></a> 4. 求解方程</h3>
<p>求解(式4)时，<img src="https://latex.codecogs.com/gif.latex?$b_1,b_2$" title="$b_1,b_2$">为各点邻接的边界点相应<img src="https://latex.codecogs.com/gif.latex?$x,y$" title="$x,y$">坐标的和，<img src="https://latex.codecogs.com/gif.latex?$x,y$" title="$x,y$">矩阵为各内部点相应分量构成的列向量。求解矩阵用到的是。<a href="https://blog.csdn.net/jiang_he_hu_hai/article/details/78207619" target="_blank" rel="noopener">Eigen库中的LU分解的方法</a>。</p>
<hr>
<h2 id="总结"><a class="markdownIt-Anchor" href="#总结"></a> 总结</h2>
<p>(式3)到(式4)的变换可以自己举例帮助理解。最后展示一下camel_head和cat_head两个三角网格的处理结果。</p>
<p><img src="/2018/11/16/三维网格平面参数化(一)/test.jpg" alt="camel_head原网格"></p>
<p><img src="/2018/11/16/三维网格平面参数化(一)/jieguo.jpg" alt="camel_head参数化后"></p>
<p><img src="/2018/11/16/三维网格平面参数化(一)/test2.jpg" alt="cat_head原网格"></p>
<p><img src="/2018/11/16/三维网格平面参数化(一)/jieguo2.jpg" alt="cat_head参数化后"></p>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/2018/11/16/三维网格平面参数化(一)/">三维网格平面参数化(一)</a></p>
        <p><span>文章作者:</span><a href="/" title="回到主页">qq</a></p>
        <p><span>发布时间:</span>2018-11-16, 02:00:49</p>
        <p><span>最后更新:</span>2018-11-27, 23:52:31</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/2018/11/16/三维网格平面参数化(一)/" title="三维网格平面参数化(一)">http://huaqq.github.io/2018/11/16/三维网格平面参数化(一)/</a>
            <span class="copy-path" data-clipboard-text="原文: http://huaqq.github.io/2018/11/16/三维网格平面参数化(一)/　　作者: qq" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target="_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/2019/03/04/Spring——Hello/">
                    Spring——Hello
                </a>
            </div>
        
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#方法思想"><span class="toc-number">1.</span> <span class="toc-text"> 方法思想</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#方法步骤"><span class="toc-number">2.</span> <span class="toc-text"> 方法步骤</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-寻找网格边界点"><span class="toc-number">2.1.</span> <span class="toc-text"> 1. 寻找网格边界点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-边界点映射到二维平面上"><span class="toc-number">2.2.</span> <span class="toc-text"> 2. 边界点映射到二维平面上</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-构造稀疏矩阵a"><span class="toc-number">2.3.</span> <span class="toc-text"> 3. 构造稀疏矩阵A</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-求解方程"><span class="toc-number">2.4.</span> <span class="toc-text"> 4. 求解方程</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#总结"><span class="toc-number">3.</span> <span class="toc-text"> 总结</span></a></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录" title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"三维网格平面参数化(一)　| Lionqq's Blog　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    




    <div class="scroll" id="post-nav-button">
        
            <a href="/2019/03/04/Spring——Hello/" title="上一篇: Spring——Hello">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/" title="回到主页"><i class="fa fa-home"></i></a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2019/04/04/初学three-js（一）/">初学three.js（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/04/02/Java/">Java复习</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/03/04/Spring——Hello/">Spring——Hello</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/11/16/三维网格平面参数化(一)/">三维网格平面参数化(一)</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2016-2019 qq
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style="display:none">
                        <span id="site-visit" title="本站到访数"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style="display:none">
                        <span id="page-visit" title="本页阅读量"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>





<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
            
            
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>